package com.zbkj.admin.controller.platform.shop;

import com.github.pagehelper.PageInfo;
import com.zbkj.common.model.shop.EbGroupBuyShop;
import com.zbkj.common.request.EbGroupBuyShopRequest;
import com.zbkj.common.response.EbGroupBuyShopResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.EbGroupBuyShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/api/admin/platform/ebGroupBuyShop")
@Api(tags = "团购商家管理")
public class PlatformGroupBuyShopController {
    @Resource
    EbGroupBuyShopService ebGroupBuyShopService;

    /**
     * 增加团购店铺
     *
     * @param ebGroupBuyShopRequest
     * @return
     */
    @ApiOperation(value = "增加团购店铺")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public CommonResult<EbGroupBuyShop> add(@RequestBody EbGroupBuyShopRequest ebGroupBuyShopRequest) {
        return CommonResult.success(ebGroupBuyShopService.add(ebGroupBuyShopRequest));
    }


    /**
     * 修改团购店铺
     *
     * @param ebGroupBuyShopRequest
     * @return
     */
    @ApiOperation(value = "修改团购店铺")
    @PostMapping(value = "/update")
    public CommonResult<EbGroupBuyShop> update(@RequestBody EbGroupBuyShopRequest ebGroupBuyShopRequest) {
        return CommonResult.success(ebGroupBuyShopService.update(ebGroupBuyShopRequest));
    }    /**
     * 修改团购店铺
     *
     * @param ebGroupBuyShopRequest
     * @return
     */
    @ApiOperation(value = "审核团购店铺")
    @PostMapping(value = "/check")
    public CommonResult<EbGroupBuyShop> check(@RequestBody EbGroupBuyShopRequest ebGroupBuyShopRequest) {
        return CommonResult.success(ebGroupBuyShopService.check(ebGroupBuyShopRequest));
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询详情")
    @GetMapping(value = "/get/{id}")
    public CommonResult<EbGroupBuyShopResponse> get(@PathVariable("id") Long id) {
        return CommonResult.success(ebGroupBuyShopService.getById(id));
    }

    /**
     * 查询列表
     *
     * @return
     */
    @ApiOperation(value = "查询列表")
    @PostMapping(value = "/getList")
    public CommonResult<List<EbGroupBuyShopResponse>> getList(@RequestBody EbGroupBuyShopRequest ebGroupBuyShopRequest) {
        return CommonResult.success(ebGroupBuyShopService.getList(ebGroupBuyShopRequest));
    }


    @ApiOperation(value = "分页查询列表")
    @PostMapping(value = "/getPage")
    public CommonResult<PageInfo<EbGroupBuyShopResponse>> getPage(@RequestBody EbGroupBuyShopRequest ebGroupBuyShopRequest) {
        return CommonResult.success(ebGroupBuyShopService.getPage(ebGroupBuyShopRequest));
    }
    @ApiOperation(value = "查询店铺数量")
    @PostMapping(value = "/getStatusCount")
    public CommonResult<Map<String,Object>> getStatusCount() {
        return CommonResult.success(ebGroupBuyShopService.getStatusCount());
    }
}